<template>
  <el-form
      :model="userDetail"
      label-width="auto"
  >
    <el-form-item label="ID">
      <el-input v-model="userDetail.id" autocomplete="off" :disabled="true"/>
    </el-form-item>
    <el-form-item label="账号">
      <el-input v-model="userDetail.loginAct" autocomplete="off" :disabled="true"/>
    </el-form-item>
    <el-form-item label="密码" >
      <el-input v-model="userDetail.loginPwd" type="password" :disabled="true" autocomplete="off"/>
    </el-form-item>
    <el-form-item label="姓名" >
      <el-input v-model="userDetail.name" :disabled="true" autocomplete="off"/>
    </el-form-item>
    <el-form-item label="手机">
      <el-input v-model="userDetail.phone" :disabled="true" autocomplete="off"/>
    </el-form-item>
    <el-form-item label="邮箱" >
      <el-input v-model="userDetail.email" :disabled="true" autocomplete="off"/>
    </el-form-item>
    <el-form-item label="账号未过期" >
      <el-select v-model="userDetail.accountNoExpired" :disabled="true"
      >
        <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value"/>
      </el-select>
    </el-form-item>
    <el-form-item label="密码未过期">
      <el-select v-model="userDetail.credentialsNoExpired" :disabled="true">
        <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value"/>
      </el-select>
    </el-form-item>
    <el-form-item label="账号是否锁定">
      <el-select v-model="userDetail.accountNoLocked" :disabled="true">
        <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value"/>
      </el-select>
    </el-form-item>
    <el-form-item label="账号是否启用">
      <el-select v-model="userDetail.accountEnabled" :disabled="true">
        <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value"/>
      </el-select>
    </el-form-item>
    <el-form-item label="创建时间" >
      <el-input v-model="userDetail.createTime" autocomplete="off" :disabled="true"/>
    </el-form-item>
    <el-form-item label="创建人" >
      <el-input v-model="userDetail.createByDo.name" autocomplete="off" :disabled="true"/>
    </el-form-item>
    <el-form-item label="编辑时间">
      <el-input v-model="userDetail.editTime" autocomplete="off" :disabled="true"/>
    </el-form-item>
    <el-form-item label="编辑人">
      <el-input v-model="userDetail.editByDo.name" autocomplete="off" :disabled="true"/>
    </el-form-item>
    <el-form-item label="最近登录时间">
      <el-input v-model="userDetail.lastLoginTime" autocomplete="off" :disabled="true"/>
    </el-form-item>
    <el-button type="primary" @click="goBack">返回</el-button>
  </el-form>
</template>
<script>
import {doGet} from "../http/HttpRequest.js";

export default {
  name: "UserDetailView.vue",
  data() {
    return {
      userDetail: {editByDo: {}, createByDo: {} },
      options: [
        {value: 1, label: '是',},
        {value: 0, label: '否',},
      ],
    }
  },
  mounted() {
    this.getUserDetailById();
  },
  methods: {
    getUserDetailById(){
      console.log("this.$route", this.$route.params.id);
      let userId = this.$route.params.id
      debugger
      doGet("/api/user/"+userId, {}).then(resp => {
        if (resp.data.code === 200) {
          debugger
          this.userDetail = resp.data.data;
          // messageTip("", "success");
          if (this.userDetail.createByDo === null) {
            this.userDetail.createByDo = {};
          }
          if (this.userDetail.editByDo === null) {
            this.userDetail.editByDo = {};
          }
        }
      })
    },
    goBack() {
      // 下面两行代码任选其一，因为back函数，最终还是调用的go(-1)
      this.$router.back();
      // this.$router.go(-1);
    }
  }
}
</script>

<style scoped>
</style>